package com.xhsj.user.lsm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xhsj.user.hr.process.hrLeaveProcess.vo.FindToDoListVo;
import com.xhsj.user.lsm.entity.TbBadgesUseApply;
import com.xhsj.user.lsm.model.MyBadgesUseApplyModel;
import com.xhsj.user.lsm.model.TaskModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 证章使用申请 Mapper 接口
 * </p>
 *
 * @author suxiaolin
 * @since 2020-03-16
 */
@Mapper
public interface TbBadgesUseApplyMapper extends BaseMapper<TbBadgesUseApply> {

    /**
     * 查询历史任务
     * @author 苏小林
     * @date 2020/3/19 16:30
     * @param: page
     * @param: userId
     * @param: status
     * @return: com.baomidou.mybatisplus.core.metadata.IPage<java.util.Map<java.lang.String,java.lang.Object>>
     */
    IPage<Map<String, Object>> findHiTaskList(IPage<TaskModel> page, @Param("userId") String userId,
                                              @Param("name") String name,
                                              @Param("applyReason") String applyReason,
                                              @Param("proposerName") String proposerName);

    /**
     * 查询未审核
     * @author 苏小林
     * @date 2020/3/19 16:43
     * @param: page
     * @param: userId
     * @param: roleList
     * @return: com.baomidou.mybatisplus.core.metadata.IPage<com.xhsj.badges.process.model.TaskModel>
     */
    IPage<Map<String, Object>> findRunTaskList(Page<TaskModel> page, @Param("userId") String userId,
                                               @Param("roleList") List<String> roleList, @Param("applyReason") String applyReason);

    /**
     * 查询使用记录
     * @author 苏小林
     * @date 2020/3/24 11:14
     * @param: id
     * @param: nodeName
     * @return: java.util.List<java.util.Map>
     */
    IPage<Map<String,Object>> findUserRecord(IPage page, @Param("id") String id, @Param("nodeName") String nodeName);

    Integer delById(@Param("id") String id);

    IPage<Map<String,Object>> getUseList(Page<TbBadgesUseApply> page, @Param("name") String name, @Param("applyReason") String applyReason,
                                         @Param("acType") Integer acType, @Param("list") List<String> list);

    /**
     * 查询合同申请正在运行中数据
     * @author 苏小林
     * @date 2020/5/12 9:25
     * @param: page
     * @param: userId
     * @param: roleList
     * @param: applyReason
 * @return: com.baomidou.mybatisplus.core.metadata.IPage<java.util.Map<java.lang.String,java.lang.Object>>
     */
    IPage<Map<String, Object>> findContractRunTaskList(Page<TaskModel> page, @Param("userId") String userId,
                                                       @Param("roleList") List<String> roleList, @Param("applyReason") String applyReason,
                                                       @Param("contractNo") Object contractNo, @Param("partiesName") Object partiesName);

    IPage<Map<String, Object>> findContractHiTaskList(IPage<TaskModel> page, @Param("userId") String userId,
                                                      @Param("status") Integer status,
                                                      @Param("roleList") List<String> roleList,
                                                      @Param("type") int type,
                                                      @Param("contractNo") Object contractNo, @Param("partiesName") Object partiesName);

    IPage<Object> findBadgesList(IPage<TbBadgesUseApply> page, @Param("userId") String userId);

    Map<String, String> getTransferByDataId(@Param("id") String id);

    IPage<Map<String, Object>> getTransferList(IPage<Object> iPage,
                                               @Param("userId") String userId,
                                               @Param("modelType") int modelType,
                                               @Param("taskType") int taskType,
                                               @Param("receivingStatus") int receivingStatus,
                                               @Param("applyType") String applyType);

    IPage<MyBadgesUseApplyModel> myBadgesUseApplyList(Page<MyBadgesUseApplyModel> page, @Param("userId") String userId);

    // 证章代办数
    Integer badgesAgencyNum(@Param("userId") Integer userId, @Param("roleList") List<String> roleList, @Param("type") Integer type);

    // 合同代办数
    Integer contractAgencyNum(@Param("userId") Integer userId, @Param("roleList") List<String> roleList, @Param("type") Integer type);

    List<FindToDoListVo> findToList(@Param("userId") Long userId, @Param("roleIds") List<Long> roleIds);

    String getFullNameByDataId(@Param("dataId") String dataId);

//    部门用章统计
    List<Map<String, Integer>> getBadgesStatistics(@Param("date") String date,@Param("isNow") boolean isNow);
}
